🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / common / src / commonMain / kotlin / org / meshtastic / core / common / util / AddressUtils.kt
Displaying Raw • Download
core/common/src/commonMain/kotlin/org/meshtastic/core/common/util/AddressUtils.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 1.96 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.common.util
T8b949e/**
* Normalizes a BLE/device address to a canonical uppercase form with colons removed. Returns `"DEFAULT"` for null,
* blank, or sentinel values (`"N"`, `"NULL"`).
*/
Tff7b72fun Td2a8ffnormalizeAddressTb4b4b4(Te6edf3addrTb4b4b4: Tffa657String?Tb4b4b4)Tb4b4b4: Tffa657String Tb4b4b4{
Tff7b72val Te6edf3u Tff7b72= Te6edf3addrTff7b72?.Te6edf3trimTb4b4b4(Tb4b4b4)Tff7b72?.Te6edf3uppercaseTb4b4b4(Tb4b4b4)
Tff7b72return Tff7b72when Tb4b4b4{
Te6edf3uTb4b4b4.Te6edf3isNullOrBlankTb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Ta5d6ff"Ta5d6ffDEFAULTTa5d6ff"
Te6edf3u Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffNTa5d6ff" Tff7b72|Tff7b72| Te6edf3u Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffNULLTa5d6ff" Tff7b72-Tff7b72> Ta5d6ff"Ta5d6ffDEFAULTTa5d6ff"
Tff7b72else Tff7b72-Tff7b72> Te6edf3uTb4b4b4.Te6edf3replaceTb4b4b4(Ta5d6ff"Ta5d6ff:Ta5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff"Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
T8b949e/**
* True iff [normalized] (the output of [normalizeAddress]) is a no-device sentinel that DB naming collapses to the
* default database. Single source of truth for "no real device selected".
*/
Tff7b72fun Td2a8ffisNoDeviceSentinelTb4b4b4(Te6edf3normalizedTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Te6edf3normalized Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffDEFAULTTa5d6ff" Tff7b72|Tff7b72| Te6edf3normalized Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ff.NTa5d6ff"
T8b949e/**
* True iff [address] refers to a real selected device. Rejects null/blank and all legacy no-device sentinels (`"n"`,
* `"null"`, `".n"`, `"default"`, case-insensitive) by delegating to [normalizeAddress] and [isNoDeviceSentinel]. Any
* input that [buildDbName] would collapse to `DEFAULT_DB_NAME` is rejected here too, so the foreground-service
* stay-alive decision and the DB name resolution can never diverge.
*/
Tff7b72fun Td2a8ffisValidDeviceAddressTb4b4b4(Te6edf3addressTb4b4b4: Tffa657String?Tb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Tff7b72!Te6edf3isNoDeviceSentinelTb4b4b4(Te6edf3normalizeAddressTb4b4b4(Te6edf3addressTb4b4b4)Tb4b4b4)
Served by rngit 1.5.0 - Generated in 0.04s